package com.example.concurrent.chapter01;

import java.util.concurrent.TimeUnit;

/**
 * @author Create By Liuqz
 * @date 2018/11/19 9:45
 */
public class TryConcurrency {

    public static void main(String[] args) {
//        new Thread(() -> enjoyMusic()).start();
        new Thread(TryConcurrency::enjoyMusic).start();
        browseNews();
    }

    private static void browseNews() {
        for (; ; ) {
            System.out.println("Un-huh, the good news.");
            sleep(1);
        }
    }


    private static void enjoyMusic() {
        for (; ; ) {
            System.out.println("Un-huh, the nice music");
            sleep(1);
        }
    }

    private static void sleep(int seconds) {
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
